package org.jetlinks.pro.koudai.web;


import io.swagger.v3.oas.annotations.tags.Tag;
import org.hswebframework.web.authorization.annotation.Resource;
import org.jetlinks.pro.koudai.Services.CourseService;
import org.jetlinks.pro.koudai.Services.QuestionService;
import org.jetlinks.pro.koudai.entity.CourseEntity;
import org.jetlinks.pro.koudai.entity.QuestionEntity;
import org.jetlinks.pro.koudai.tenant.KoudaiAssetType;
import org.jetlinks.pro.tenant.AssetType;
import org.jetlinks.pro.tenant.crud.TenantCorrelatesAccessCrudController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Nonnull;
import java.util.function.Function;

@RestController
@RequestMapping("/question")
@Resource(id = "question-manager", name = "试题管理")
@Tag(name = "试题管理")
public class QuestionController implements TenantCorrelatesAccessCrudController<QuestionEntity, String> {

    private final QuestionService questionService;

    public QuestionController(QuestionService courseService) {
        this.questionService = courseService;
    }


    @Override
    public QuestionService getService() {
        return questionService;
    }

    @Nonnull
    @Override
    public AssetType getAssetType() {
        return KoudaiAssetType.question;
    }

    @Nonnull
    @Override
    public Function<QuestionEntity, ?> getAssetIdMapper() {
        return QuestionEntity::getId;
    }

    @Nonnull
    @Override
    public String getAssetProperty() {
        return "question";
    }
}
